<?php

require_once 'Zend/Validate/Abstract.php';

class Kzend_Validate_Numeric extends Zend_Validate_Abstract
{
    const NOT_CORRECT = 'notCorrect';

    protected $_labelName = '';

    protected $_messageTemplates = array(
            self::NOT_CORRECT => '%labelName% must be a numerical value.',);

    protected $_messageVariables = array(
            'labelName' => '_labelName',);

    public function __construct($labelName)
    {
        $this->_labelName = $labelName;
    }

    public function isValid($value)
    {
        $valueString = (string) $value;
        $this->_setValue($valueString);
        $result = Kzend_StringUtil::isNumeric($valueString);
        if (false == $result) {
            $this->_error(self::NOT_CORRECT);
            return false;
        } else {
            return true;
        }
    }
}
